<?php
/**
 * Copyright (c) [2019] [吴跃忠]
 * [selibra] is licensed under the Mulan PSL v1.
 * You can use this software according to the terms and conditions of the Mulan PSL v1.
 * You may obtain a copy of Mulan PSL v1 at:
 * http://license.coscl.org.cn/MulanPSL
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
 * PURPOSE.
 * See the Mulan PSL v1 for more details.
 */

namespace Selibra\WebSocket\Commands;

use Selibra\Tools\Console;
use Selibra\Di\Annotations\Autowired;
use Selibra\Command\Annotations\Command;
use Selibra\WebSocket\WSServer;
use Symfony\Component\Console\Command\Command as ConsoleCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Class WSStartCommand
 * @package Selibra\WebSocket\Commands
 */
#[Command("websocket")]
class WSStartCommand extends ConsoleCommand
{

    /**
     * @Autowired()
     * WebSocket服务控制
     * @var WSServer
     */
    #[Autowired]
    public WSServer $wsServer;

    protected function configure()
    {
        $this->setName('ws:start');
        // ...
    }


    /**
     * @param InputInterface $input
     * @param OutputInterface $output
     * @return int
     */
    public function execute(InputInterface $input, OutputInterface $output)
    {
        Console::log("=========WebSocketServer Start===========");
        $this->wsServer->start();
        return 0;
    }
}